#!/usr/bin/env python3
# -*- coding: utf -8 -*-
# test xpath fuzzy location

from selenium import webdriver
import time
import re


url = 'https://www.baidu.com'
driver = webdriver.Chrome()
driver.get(url)
driver.implicitly_wait(3)

el1 = driver.find_element_by_xpath('//*[@id="su"]')
print('el1\n', el1)
el2 = driver.find_element_by_xpath("//*[contains(@id, 'su')]")
print('el2\n', el2)
el3 = driver.find_element_by_xpath("//*[contains(@value, '百度一')]")
print('el3\n', el3)
el4 = driver.find_element_by_xpath("//*[starts-with(@value, '百度一')]")
print('el4\n', el4)
# el5 = driver.find_element_by_xpath("//*[ends-with(@text, '产品')]")
# print('el5\n', el5)
# el6 = driver.find_element_by_xpath("//*[match(@id, 'su')]")
# print('el6\n', el6)
# js = "arguments[0].style.border='2px solid red'"

# driver.execute_script(js, )



